With improvement of the infrastructure of broadband networks, streaming services are more and more extensively applied. In a streaming application, when a streaming server receives a play request from a client, the streaming server reads media data from a media file, including video and audio data, and transfers the data to the client continuously in real time. In the Video on Demand (VoD) application, a client can also issue fast forward or fast backward commands to the streaming server so that the user can view contents before or after the current picture.
A media file is usually large in size and therefore needs to be compressed so as to reduce the cost of storage devices and the bandwidth required for transporting media streams. So far, there are three methods for compressing media data. These three methods are common known in the concerned field and therefore not described further here.
Different compression methods achieve different compression effects. Using the prior three methods to compress media data will generate three types of video data frames, specifically, I frame, P frame and B frame. The I frame does not require other reference frames. Compared with the P frame and the B frame, an I frame needs a larger amount of data; a P frame needs about half the amount of data needed by an I frame and a B frame needs about ¼ the amount of data needed by an I frame. In addition, because the P frame and the B frame require other reference frames, once some media data is lost during transportation, the error will exist at all time so that the image cannot be restored. Therefore, an I frame is sent at a regular interval during transport of a media stream for restoration upon error. Between every two I frames, there are usually 12 to 15 P frames or B frames.
Even though multiple compression technologies are adopted, a media file is still large and as a result, it is time consuming to read a media file and stream media data. To minimize the time to read and transport media stream data, when processing a fast forward play request or a fast backward play request, a streaming application does not simply send media stream data at a higher speed. Instead, it minimizes the amount of transferred media data on the condition of satisfying user experience.
In a first method for fast forward/backward play of a video file in the prior art, I frames of the original media file are extracted out and one or more zero frames (ZPs) are inserted between adjacent I frames according to the size of I frames at different time to create a new I frame file, together with an I frame index file. The ZP is a type of P frame, which has the same image contents as the previous I frame. The ZP is inserted to guarantee that the output bit rate at the time of fast forward/backward play of a video stream is the same as that at the time of normal play.
Upon receipt of a fast forward or fast backward play request, a streaming server first determines the first I frame to be transmitted according to the command type of the play request and the image currently being transmitted; then the streaming server locates the first I frame in the index file according to the sequence number of the first I frame to be transmitted and determines the number of ZP frames to be inserted according to the size of the first I frame; the streaming server sends the first I frame and the ZP frame(s) to be inserted to the network via a stream generator. Then the streaming server sends the following I frames and ZP frames in the same steps.
In a second method for fast forward/backward play of video data in the prior art, the streaming server first extracts all I frames from an obtained original media file to form an I frame sequence. To ensure that the output bit rate of video data in fast forward or fast backward play is the same as that in normal play, the streaming server determines the size of a standard I frame according to the number of frames played by the player in a second, the network transport bit rate (TBR) and the video bit rate (VBR), and modifies the input I frame to the size of the standard I frame. The modified I frame is called a T frame. One or more B or P frames are inserted between two adjacent T frames. These B or P frames have the same image contents as the adjacent I frame so that the played image is smoother. The streaming server uses the generated T frame sequence directly to form a media file for fast forward and modifies the time stamp in the T frame sequence to form a media file for fast backward. Meanwhile, the streaming server generates an index file. When normal play is switched to fast forward, the streaming server searches the index file for the next I frame to be transmitted in the original media file, finds the T frame in the fast forward media file corresponding to the I frame, and then reads and transmits the T frame and the video data after the T frame from the fast forward media file; when fast forward is switched to normal play, the streaming server searches the index file for the next T frame to be transmitted in the fast forward media file, finds the I frame in the original media file corresponding to the T frame, and then reads and transmits the I frame and the video data after the I frame from the original media file. Back forwarding is processed in a similar way with a difference in that the fast backward media file is used.
The inventor finds that the two methods enable the streaming server to output video data in fast forward or fast backward in the same bit rates as in normal play. Because all I frames are extracted and stored as a separate fast forward and fast backward media file, multiple I frames can be read at a time, which improves the efficiency in reading I frames to some extent. However, the two methods do not consider that it is not necessary to transmit all I frames when the scale for fast forward/backward increases. Usually, fast forward/backward scale can be 2 times (2×), 4×, 8×, 16× and 32× as high as the normal scale. When the scale is high, like 32×, the reading efficiency with adoption of the two methods in the prior art is only 6.25%. In addition, to read and transmit all I frames for high scale fast forward/backward may go beyond the read capacity of the hard disk, the transport bandwidth of the network, and the receipt capacity of the client. Therefore, in the case of high scale fast forward/backward, it is necessary to discard some I frames at certain time intervals so that most data read from the fast forward/backward media file need be discarded. The processing capability of the hard disk is therefore wasted and the number of concurrent fast forward/backward sessions the system can support also drops. As a result, the streaming server cost apportioned to each user is increased.